﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
public class PancakeBehaviour : MonoBehaviour {
	Animator MyAnim;
	bool doneAnim;
	void Start(){
		MyAnim = GetComponent<Animator> ();

	}
	IEnumerator Shocked(){
		MyAnim.SetInteger ("EyesStat", 2);
		yield return new WaitForSecondsRealtime (0.8f);
		MyAnim.SetInteger ("EyesStat", 1);
	}
	void OnCollisionEnter2D(Collision2D Col){
		if (Global.gameStart == true) {
			
			if (Col.gameObject.tag == "GameOver") {
				Camera.main.GetComponent<Global> ().GameOver ();
			}
			else {
				
				if (doneAnim == false) {
					doneAnim = true;
					MyAnim.SetInteger ("EyesStat", 1);
					if (Global.PanCakesNumber > 1) {
						if (Mathf.Abs (transform.position.x - Col.gameObject.transform.position.x) > 0.22f) {
							StartCoroutine ("Shocked");
						}
					}
				}

			}
		}
	}

}
